<template>
  <div>
    <div class="tb">
      <div>
        <div class="bor">
          <!-- 上面两台 -->
          <div class="workOrder">
            <div>日销售统计</div>
            <el-row class="ri">
              <el-col :span="6">
                <div>1</div>
                <span>当日销售量(个)</span>
              </el-col>
              <el-col :span="6">
                <div>1</div>
                <span>当日销售量(个)</span>
              </el-col>
              <el-col :span="6">
                <div>1</div>
                <span>当日销售量(个)</span>
              </el-col>
              <el-col :span="6">
                <div>1</div>
                <span>当日销售量(个)</span>
              </el-col>
            </el-row>
          </div>
          <div class="sell">
            <div>月销售统计</div>
            <el-row class="yue">
              <el-col :span="12">
                <div>1</div>
                <span>当日销售量(个)</span>
              </el-col>
              <el-col :span="12">
                <div>1</div>
                <span>当日销售量(个)</span>
              </el-col>
            </el-row>
          </div>
        </div>
        <!-- 销售数据 -->
        <salesData />
      <!-- 热门排行 -->
      </div>
      <hotList />
    </div>
    <bottom />
  </div>
</template>

<script>
import salesData from './components/salesData.vue'
import hotList from './components/hotList.vue'
import bottom from './components/bottom.vue'
import moment from 'moment'
import { condition, Sales } from '@/api'
export default {
  name: 'Dashboard',
  components: {
    salesData, hotList, bottom
  },
  data() {
    return {
      start: '2022-10-01 00:00:00', // 开始
      sStart: '2022-10-01',
      end: this.formatDate(new Date().getTime()), // 结束
      sEnd: this.SalesData(new Date().getTime()), // 结束
      total: 0, // 工单总数
      completedTotal: 0, // 完成数
      progressTotal: 0, // 进行中
      cancelTotal: 0 // 取消数
    }
  },
  async created() {
    // 工单统计的接口
    const { data } = await condition(this.start, this.end)
    data.forEach((item) => {
      this.total += item.total
      this.completedTotal += item.completedTotal
      this.cancelTotal += item.cancelTotal
      this.progressTotal += item.progressTotal
    })
    console.log(data)
    // 销售额统计
    const res = await Sales(1, this.sStart, this.sEnd)
    console.log(res)
  },
  methods: {
    // 带时分秒
    formatDate(val) {
      return moment(val).format('YYYY-MM-DD' + ' HH:mm:ss')
    },
    // 不带时分秒
    SalesData(val) {
      return moment(val).format('YYYY-MM-DD')
    }
  }
}
</script>
<style lang="scss" scoped>
.tb{
 display: flex;
  justify-content: space-between;
}
.hotList {
  // float: right;
}
.bor {
  width: 1380px;
  padding: 20px;
  // display: flex;
  justify-content: space-between;
}
.workOrder {
  display: inline-block;
  width: 700px;
  background: #e9f3ff;
  background-image: url(),
    url(http://likede2-admin.itheima.net/img/task.66b715b7.png);
  background-repeat: no-repeat, no-repeat;
  background-position: 0 0, calc(100% - 12px) 100%;
  // display: flex;
  flex-direction: column;
  height: calc(20vh - 24px);
  min-height: 166px;
  padding: 20px;
  border-radius: 30px;
  margin-right: 20px;
}
.sell {
  display: inline-block;
  width: 600px;
  height: 160px;
  border-radius: 30px;
  // background-color: #fbefe8;
  background: #fbefe8
    url(http://likede2-admin.itheima.net/img/sale.606b0d8c.png) no-repeat
    calc(100% - 12px) 100%;
  padding: 20px;
  flex-direction: column;
}

.yue {
  // margin-left: 60px;
  div {
    color: #ff5757;
    text-shadow: 2px 4px 7px rgb(255 99 85 / 50%);
    height: 50px;
    font-size: 36px;
    font-weight: 600;
    line-height: 50px;
  }
  span {
    height: 17px;
    margin-top: 3px;
    font-size: 12px;
    font-weight: 400;
    color: #de9690;
    line-height: 17px;
  }
}
.ri {
  margin-left: 60px;
  div {
    color: #072074;
    text-shadow: 2px 4px 7px rgb(85 132 255 / 50%);
    height: 50px;
    font-size: 36px;
    font-weight: 600;
    line-height: 50px;
  }
  span {
    height: 17px;
    margin-top: 3px;
    font-size: 12px;
    font-weight: 400;
    color: #91a7dc;
    line-height: 17px;
  }
}
.yue {
  margin-left: 60px;
  div {
    color: #ff5757;
    text-shadow: 2px 4px 7px rgb(255 99 85 / 50%);
    height: 50px;
    font-size: 36px;
    font-weight: 600;
    line-height: 50px;
  }
  span {
    height: 17px;
    margin-top: 3px;
    font-size: 12px;
    font-weight: 400;
    color: #de9690;
    line-height: 17px;
  }
}
</style>
